/*
 * ExperimentalParametersPanelHandler
 * 
 * Version: 1.0: This class is responsible for generating Experimental Parameters Panel which lets users select
 * Experiments Parameters as in Tempo wherever applicable.
 * 
 * Date: 12/05/2010
 * 
 * Licensed under Eclipse open source license
 */
package slhs.tempo.scriptGenerator;

import java.awt.Component;
import java.awt.event.ActionEvent;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import org.mlc.swing.layout.LayoutConstraintsManager;

import com.jgoodies.forms.factories.DefaultComponentFactory;

public class FeedbackOptionsPanelHandler extends JPanel implements PanelHandler {

    private Component correctAnswerParametersSeperator;
    private Component wrongAnswerParametersSeperator;

    private JCheckBox wrongAnswerImageFeedbackCheckbox;
    private JCheckBox correctAnswerImageFeedbackCheckbox;
    private JCheckBox wrongAnswerAudioFeedbackCheckbox;

    private JTextField wrongAnswerImageFeedbackTextField;
    private JTextField correctAnswerAudioFeedbackTextField;
    private JTextField correctAnswerImageFeedbackTextField;
    private JTextField wrongAnswerAudioFeedbackTextField;

    private JComboBox wordFeedbackComboBox;
    private JCheckBox correctAnswerAudioFeedbackCheckbox;

    private JLabel wordFeedbackLabel;

    private JButton wrongAnswerBackgroundChooseColorButton;
    private JButton wrongAnswerForegroundChooseColorButton;
    private JButton correctAnswerForegroundChoseColorButton;
    private JButton correctAnswerBackgroundChooseColorButton;

    private static final String FEEDBACK_OPTIONS_PANEL_LAYOUT = "FEEDBACK_OPTIONS_LAYOUT.XML";

    private final JPanel feedbackOptionsPanel;

    public FeedbackOptionsPanelHandler() {

	feedbackOptionsPanel = new JPanel();

	// initialize components to be added
	initComponents();
	addComponents();

    }

    private void addComponents() {
	LayoutConstraintsManager layoutConstraintsManager = LayoutConstraintsManager.getLayoutConstraintsManager(this
		.getClass().getResourceAsStream(FEEDBACK_OPTIONS_PANEL_LAYOUT));
	feedbackOptionsPanel.setLayout(layoutConstraintsManager.createLayout("feedbackOptionsPanel",
		feedbackOptionsPanel));

	feedbackOptionsPanel.add(correctAnswerParametersSeperator, "correctAnswerParametersSeperator");
	feedbackOptionsPanel.add(wrongAnswerImageFeedbackTextField, "wrongAnswerImageFeedbackTextField");
	feedbackOptionsPanel.add(wrongAnswerBackgroundChooseColorButton, "wrongAnswerBackgroundChooseColorButton");
	feedbackOptionsPanel.add(wrongAnswerImageFeedbackCheckbox, "wrongAnswerImageFeedbackCheckbox");
	feedbackOptionsPanel.add(wrongAnswerForegroundChooseColorButton, "wrongAnswerForegroundChooseColorButton");
	feedbackOptionsPanel.add(correctAnswerAudioFeedbackTextField, "correctAnswerAudioFeedbackTextField");
	feedbackOptionsPanel.add(correctAnswerForegroundChoseColorButton, "correctAnswerForegroundChoseColorButton");
	feedbackOptionsPanel.add(correctAnswerImageFeedbackTextField, "correctAnswerImageFeedbackTextField");
	feedbackOptionsPanel.add(correctAnswerImageFeedbackCheckbox, "correctAnswerImageFeedbackCheckbox");
	feedbackOptionsPanel.add(wordFeedbackComboBox, "wordFeedbackComboBox");
	feedbackOptionsPanel.add(correctAnswerAudioFeedbackCheckbox, "correctAnswerAudioFeedbackCheckbox");
	feedbackOptionsPanel.add(correctAnswerBackgroundChooseColorButton, "correctAnswerBackgroundChooseColorButton");
	feedbackOptionsPanel.add(wordFeedbackLabel, "wordFeedbackLabel");
	feedbackOptionsPanel.add(wrongAnswerParametersSeperator, "wrongAnswerParametersSeperator");
	feedbackOptionsPanel.add(wrongAnswerAudioFeedbackCheckbox, "wrongAnswerAudioFeedbackCheckbox");
	feedbackOptionsPanel.add(wrongAnswerAudioFeedbackTextField, "wrongAnswerAudioFeedbackTextField");
    }

    private void initComponents() {
	correctAnswerParametersSeperator = DefaultComponentFactory.getInstance().createSeparator(
		"Correct Answer Feedback Configuration", SwingConstants.CENTER);

	wrongAnswerImageFeedbackTextField = new JTextField();
	wrongAnswerBackgroundChooseColorButton = new JButton("Choose");
	wrongAnswerImageFeedbackCheckbox = new JCheckBox("Image Feedback");

	wrongAnswerForegroundChooseColorButton = new JButton("Choose");

	correctAnswerAudioFeedbackTextField = new JTextField();
	correctAnswerForegroundChoseColorButton = new JButton("Choose");
	correctAnswerImageFeedbackTextField = new JTextField();
	correctAnswerImageFeedbackCheckbox = new JCheckBox("Image Feedback");
	wordFeedbackComboBox = new JComboBox();
	correctAnswerAudioFeedbackCheckbox = new JCheckBox("Audio Feedback");
	correctAnswerBackgroundChooseColorButton = new JButton("Choose");
	wordFeedbackLabel = new JLabel("Word Feedback:");
	// Use an empty string for an unlabelled separator.
	// Change to SwingConstants.RIGHT or .CENTER to change label alignment.
	wrongAnswerParametersSeperator = DefaultComponentFactory.getInstance().createSeparator(
		"Wrong Answer Feedback Configuration", SwingConstants.CENTER);
	wrongAnswerAudioFeedbackCheckbox = new JCheckBox("Audio Feedback");
	wrongAnswerAudioFeedbackTextField = new JTextField();

    }

    @Override
    public JPanel getPanel() {
	return feedbackOptionsPanel;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub

    }

}
